package com.springboot.user.controller;

import com.alibaba.fastjson.JSON;
import com.springboot.framework.config.redis.RedisUtil;
import com.springboot.framework.exception.BaseException;
import com.springboot.framework.jwt.JWTUtil;
import com.springboot.framework.jwt.PassToken;
import com.springboot.framework.mvc.controller.BaseController;
import com.springboot.framework.response.ResponseMap;
import com.springboot.framework.response.ResponseResult;
import com.springboot.user.entity.User;
import com.springboot.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController extends BaseController {
    @Autowired
    private UserService userService;

    @RequestMapping("/test")
    public String getName(){
        return "name";
    }

    @PassToken
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public ResponseMap login(User user){
        Map map = new HashMap();
        map.put("loginNum","123455");
        map.put("nickName","管管");
        List<User> list1 = userService.getByCondition(user);
        List<User> list2 =userService.getByCondition(map);
        User user1 = userService.getById(1);
        /*String token = JWTUtil.getToken(user1.getOpenId());*/
        return new ResponseMap().ok(user1).addData("list1",list1).addData("list2",list2);
    }

    @RequestMapping(value = "/test2",method = RequestMethod.GET)
    public ResponseMap test(){
        return new ResponseMap().ok().addData("test","success");
    }



}
